package com.lz.timer.an.datasource;

import javax.sql.DataSource;

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author rench
 * @Description: job 数据源
 */
@Configuration
@PropertySource(value = DataSourceConfigJob.JDBC_PROPERTIES, ignoreResourceNotFound = true)
public class DataSourceConfigJob {

    public static final String JDBC_PROPERTIES = "classpath:/jdbc.properties";
    private final static String MODEL = "job";
    private final static String DATA_SOURCE = MODEL + "DataSource";
    private final static String DATA_SOURCE_CONFIG = "spring.datasource." + MODEL;

    @Bean(name = DATA_SOURCE)
    @ConfigurationProperties(prefix = DATA_SOURCE_CONFIG)
    public DataSource jobDataSource() {
        return DataSourceBuilder.create().build();
    }

}